﻿@{
    Layout = null;
}

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>组织机构</title>
    <link rel="stylesheet" href="@ViewBag.easyuiTheme" id="easyuiTheme" />
    @Styles.Render("~/style-easyui")
</head>
<body class="easyui-layout" data-options="border:false">
    <div data-options="region:'west',border:false,title:'组织机构'" style="width: 220px;padding:5px;">
        <ul id="ulDept" class="easyui-tree" style="padding:5px;"></ul>
    </div>
    <div data-options="region:'center'">
        <iframe id="ifmList" frameborder="0" marginheight="0" marginwidth="0" style="width: 100%;height:100%" src="/System/Organ/List?ParentID=0"></iframe>
    </div>


    @Scripts.Render("~/script-easyui")
    <script type="text/javascript" src="@Url.Content("~/Scripts/public.js")"></script>
    <script type="text/javascript">
        window.isFirst = true;

        function InitDept() {
            $('#ulDept').tree({
                url: "/System/Organ/InitDeptTree",
                animate: true,
                loadFilter: function (data, parent) {
                    return data.rows;
                },
                onBeforeLoad: function (node, param) {
                    if (!node) {
                        param.ParentID = "";
                    }
                    else {
                        param.ParentID = node.id;
                    }
                },
                onClick: function (node) {
                    if (node.attributes) {
                        $("#ifmList").attr("src", node.attributes.URL);
                    }
                },
                onLoadSuccess: function (node, data) {
                    if (window.isFirst) {
                        if (data.length > 0) {
                            var node = $('#ulDept').tree('find', "0");
                            $('#ulDept').tree('select', node.target).tree('expand', node.target);
                            window.isFirst = false;
                        }
                    }
                }
            });
        }

        $(function () {
            InitDept();
        })
    </script>
</body>
</html>
